package com.hlf.common.page;

/**
 * 公共分页实体类
 *
 */
public class Page {

    private static final int DEFAULT_PAGE_SIZE = 10;
    
    /**
     * 每页显示条数
     */
    private int pageSize = DEFAULT_PAGE_SIZE;

    /**
     * 当前第几页
     */
    private int currentPage = 1;

    /**
     * 从第几条数据开始查询
     */
    @SuppressWarnings("unused")
    private int start = 0;

    /**
     * 从第几条数据结束查询
     */
    @SuppressWarnings("unused")
    private int end = 0;

    public Page() {
        super();
    }

    public Page(int pageSize) {
        super();
        this.pageSize = pageSize;
    }

    public int getStart() {
        if (this.currentPage < 1) {
            this.currentPage = 1;
        }
        return pageSize * (this.currentPage - 1);
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return pageSize * currentPage;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    @Override
    public String toString() {
        return "Page [start=" + getStart() + ", end=" + getEnd()
                + ", pageSize=" + pageSize + ", currentPage=" + currentPage
                + "]";
    }

}
